package com.ynu.springbootappdemo.model.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ynu.springbootappdemo.common.entity.LogicEntity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Setter
@Getter
@Entity
@NoArgsConstructor
@Where(clause = "is_deleted = 0")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})

public class DeliveryAddress extends LogicEntity {
    private String contactName;
    private Integer contactSex;
    private String contactTel;
    private String province;
    private String city;
    private String district;
    private String address;
    private boolean isDefaultAddress;
    @OneToOne(mappedBy = "deliveryAddress")
    private Orders order;


    @ManyToOne(cascade = CascadeType.MERGE,fetch = FetchType.EAGER)
    @JoinColumn(name = "customer_id")
    @JsonIgnoreProperties("deliveryAddresses")
    private Customer customer;
}
